home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_06 / xmpl_09.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  628 b   |  30 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 6, example 9
  5.  
  6. -- create a module to avoid namespace conflicts
  7. module Scratch31 uses ScriptX end
  8. in module Scratch31
  9.  
  10. -- defining an afterinit method
  11.  
  12. global newSameKey
  13.  
  14. class SameKey (SortedKeyedArray)
  15. instance vars key
  16. instance methods
  17. method init self #rest args #key key: -> (
  18.     apply nextMethod self args
  19.     self.key := key
  20. )
  21. method afterInit self #rest args #key vals: -> (
  22.     apply nextMethod self args
  23.     for i in vals do add self self.key i 
  24. )
  25. end
  26.  
  27. -- now test it out
  28. newSameKey := new SameKey key:@flavor \
  29.     vals:#(@cherry,@watermelon,@peach)
  30. -->>>